
var vm = new Vue({
    el : "#CPInWarehouse",
    data : {
        record:{},
        sels:[],
        table: null
    },
    ready: function(){
        var _self = this;
        this.renderTable();
        layui.use(['layer'], function(){
            layer = layui.layer;
        });
    },
    methods: {
        boxLists: function(val){
            var _self = this;
            var rfid = $("#RFID").val();
            if (rfid==null || rfid.trim() =='') {
                alert("请先扫描RFID！");
                return;
            }
            var data ={
                rfid:rfid
            };
            this.$nextTick(function() {
                this.$http.post(host +"CPInWarehouse/boxLists",data,{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.vueAlert("操作成功！");
                    }else{
                        layer.msg("操作失败");
                    }
                });
            });
        },
        rfidLists: function(event){
            var _self = this;
            var rfid = document.getElementById("RFID").value;   //作业工单RFID
            if (event && (event.keyCode != 13 || !(rfid && rfid.length > 0))) {
                return;
            }

            var data ={
                rfid : rfid
            };
            var cpInDataByCode = [];
            _self.$nextTick(function() {
                _self.$http.post(host +"CPInWarehouse/rfidLists",data,{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        if(res.body.results == 'false'){
                            _self.vueAlert(res.body.msg);
                            return;
                        }
                        _self.cpInDataByCode = res.body.rfidLists;

                        cpInDataByCode =  _self.cpInDataByCode;
                        if(cpInDataByCode[0].ZYCODE != null && cpInDataByCode[0].ZYCODE !=''){
                            document.getElementById("jobCode").innerText="工单号："+cpInDataByCode[0].ZYCODE;
                        }
                        if(cpInDataByCode[0].PRODUCT != null && cpInDataByCode[0].PRODUCT !=''){
                            document.getElementById("productName").innerText="型体："+cpInDataByCode[0].PRODUCT;
                        }
                        if(cpInDataByCode[0].YSNAME != null && cpInDataByCode[0].YSNAME !=''){
                            document.getElementById("colorName").innerText="颜色："+cpInDataByCode[0].YSNAME;
                        }
                        if(cpInDataByCode[0].TIMES != null && cpInDataByCode[0].TIMES !=''){
                            document.getElementById("inTime").innerText="下单时间："+cpInDataByCode[0].TIMES;
                        }
                        if(cpInDataByCode[0].CMCODE != null && cpInDataByCode[0].CMCODE !=''){
                            document.getElementById("size").innerText="尺码："+cpInDataByCode[0].CMCODE;
                        }
                        if(cpInDataByCode[0].YHNAME != null && cpInDataByCode[0].YHNAME !=''){
                            document.getElementById("manName").innerText="收件人："+cpInDataByCode[0].YHNAME;
                        }
                        if(cpInDataByCode[0].DIZHI != null && cpInDataByCode[0].DIZHI !=''){
                            document.getElementById("address").innerText="收件人地址："+cpInDataByCode[0].DIZHI;
                        }
                       // _self.emesoJobOrderExeId = cpInDataByCode[0].EMESO_JOB_ORDER_EXE_ID;

                        this.renderTable();

                        if(res.body.results == 'true'){
                            _self.vueAlert(res.body.msg);
                            return;
                        }


                    }
                });
            });

        },
        reset:function(data){
            window.location.reload();
        },
        vueAlert:function(msg){
            layui.use(['form'], function(){
                var layer = layui.layer;
                layer.msg(msg,{icon:6,time:2000});
            });
        },
        renderTable: function(){
            var _self = this;
            layui.use('table', function(){
                _self.table = layui.table;

                _self.listTable = _self.table.render({
                    elem: '#cpInListTable',
                    width: 'full-20',
                    height: 'full-150',
                    cols: [[ //标题栏
                        { type:'numbers',title:'序号'},
                        { field: 'JOBCODE', title: '工单号',width: 200},
                        {field: 'WLNAME', title: '型体',width: 200, align:'center' },
                        {field: 'YSNAME', title: '颜色', width: 180,align:'center'},
                        {field: 'CMCODE', title: '尺码', minWidth: 160,align:'center'},
                        {field: 'YHNAME', title: '操作人', width: 160,align:'center'},
                        {field: 'INTIMES', title: '入库时间', width: 160,align:'center'},
                        {field: 'BOXCODE', title: '包装盒条码', width: 150,align:'center'},
                        {field: 'WULIUCODE', title: '物流单号', minWidth: 80,align:'center'}
                    ]],
                    method: 'post',
                    url: host + "CPInWarehouse/HistoryList",
                    page: true, //是否显示分页
                    limits: [10, 20, 50],
                    limit: 15 //每页默认显示的数量
                });
            });
            _self.form = layui.form;
        }
    }
});